package top.kpromise.umenganalytics

import android.app.Activity
import com.umeng.analytics.MobclickAgent
import com.umeng.commonsdk.UMConfigure
import top.kpromise.ibase.IApplication
import top.kpromise.ibase.lifecycle.CommonCallBack

class UmengCallBack(nextCallBack: CommonCallBack?): CommonCallBack(nextCallBack) {

    override fun onResume(activity: Activity) {
        MobclickAgent.onResume(activity)
        super.onResume(activity)
    }

    override fun onPause(activity: Activity) {
        MobclickAgent.onPause(activity)
        super.onPause(activity)
    }

    companion object {
        private var hasInit = false
        fun init(pushSecret: String?) {
            if (hasInit) {
                return
            }
            UMConfigure.init(IApplication.app, UMConfigure.DEVICE_TYPE_PHONE, pushSecret)
            hasInit = true
        }
    }
}